<?php
include('./adm_header.php');
?>
			<div id="content">
				<h2>Manage Pages</h2>
				<?php
				$dir = "../pages/";

				if($handle = opendir($dir))
				{
					while ($file = readdir($handle))
					{
						clearstatcache();
						if(is_file($dir.$file))
						{
							$search = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9');
							$replace = array('', '', '', '', '', '' , '', '', '', '');
							$newfilename = str_replace($search, $replace, $file);
							
							echo '<div style="float: right;"><a href="./editpage.php?p=' . $file . '">Edit</a> - <a href="./deletepage.php?page=' . $file . '">Delete</a></div>';
							echo '<a href="../index.php?p=' . $file . '">' . $newfilename . '</a><br /><br />';
						}
					}
					closedir($handle);
				}
				$dir = "../pages/subpages/";

				if($handle = opendir($dir))
				{
					while ($file = readdir($handle))
					{
						clearstatcache();
						if(is_file($dir.$file))
						{
							echo '<div style="float: right;"><a href="./editsubpage.php?p=' . $file . '">Edit</a> - <a href="./deletepage.php?page=' . $file . '">Delete</a></div>';
							echo '<a href="../index.php?p=' . $file . '">' . $file . '</a><br /><br />';
						}
					}
					closedir($handle);
				}
				?>
			</div>
		</div>
	</body>
</html>